function ajaxhla2001a(ssPop, ssLocus)
{
	var objElements = document.forms[1].elements;	
  	var iTotElem = objElements.length;
	var iI;
	var sChain = "";
	var sCode = "";
	var sAFreq = "";
	var sPFreq = "";
	var fPFreq = 0.0;
	var fAFreq = 0.0;
	var iBand = 0;
	var sAllele = "";
	var sPop = "";
	var sObject1;

	ajaxhla2001a_del(ssPop, ssLocus);	
  	for(iI = 0; iI < iTotElem; iI++)
  	{	
    	if((objElements[iI].type == "text"))
		{
			if(objElements[iI].name== "txtpfreq")
			{
				sObject1 = objElements[iI].name;
				sCode = objElements[iI].id;
				sCode = sCode.substring(8);
				sChain = sCode;
				if(objElements[iI].value!="")
				{
					fPFreq = parseFloat(objElements[iI].value);					
					sPFreq = objElements[iI].value;			
				}
				else
				{
					sPFreq = "";
				}
			}
			if(objElements[iI].name== "txtafreq")
			{
				sCode = objElements[iI].id;
				sCode = sCode.substring(8);
				sAllele = sCode.substring(28);
				sPop = sCode.substring(0,8);
				sLocus = sCode.substring(8,20);				
				if(objElements[iI].value!="")
				{
					fAFreq = parseFloat(objElements[iI].value);					
					sAFreq = objElements[iI].value;
				}
				else
				{
					sAFreq = "";
				}
				//... Compare if at least one of the frequencies has a value ...//
				if((sChain == sCode)&&((sPFreq != "")||(sAFreq != "")))
				{
					alert("Saving data...\n\n" + "Pop: " + sPop + "\nLocus: " + sLocus + "\nAllele: " + sAllele + "\nFreq 1: " + sPFreq + "\nFreq 2: " + sAFreq);
					ajaxhla2001a_ins(sPop, sLocus, sAllele, sPFreq, sAFreq);
					iBand = 1;
				}
				//... Cleaning values for next comparison ...//
				sChain = "";
				sAFreq = "";
				sPFreq = "";
			}
		}
	}
	if(iBand==1)
	{
		//ajaxhla2001a_upt(ssPop, ssLocus);
		alert("Your data has been saved. Please continue filling other loci.");
		document.getElementById(sObject1).focus();		
	}
	else
	{
		alert("There is not data to be saved. Please fill the information required and then try again.");
	}	
  	return false;	
}
function ajaxhla2001a_del(sAllf_popid, sAllf_locus)
{
    var xmlHttp;
	var sURL = "ajaxhla2001a_del.asp";
	
	try
    {  
         // Firefox, Opera 8.0+, Safari  
         xmlHttp=new XMLHttpRequest();  
     }
     catch (e)
     { 
         // Internet Explorer  
         try
         {    
               xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    
         }
         catch (e)
         {    
               try
               {      
                     xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");     
               }
               catch (e)
               {      
                     //alert("Your browser does not support AJAX!");      
                     return false;      
               }    
         }  
     }
   
     xmlHttp.onreadystatechange=function()
     {
		 // ================================		 
		 //	State Description 
		 // ================================
		 //	0 The request is not initialized 
		 // 1 The request has been set up 
		 // 2 The request has been sent 
         // 3 The request is in process 
         // 4 The request is complete 
		 // ================================
         if(xmlHttp.readyState==4)
         {
               //document.getElementById("txt").value=xmlHttp.responseText;
         }
     }
	 sURL = sURL + "?" + "allf_popid=" + sAllf_popid + "&allf_locus=" + sAllf_locus;
     xmlHttp.open("GET", sURL, true);
     xmlHttp.send(null);  
}

function ajaxhla2001a_ins(sAllf_popid, sAllf_locus, sAllf_allele, sAllf_pfreq, sAllf_afreq )
{
    var xmlHttp;
	var sURL = "ajaxhla2001a_ins.asp";
	
	try
    {  
         // Firefox, Opera 8.0+, Safari  
         xmlHttp=new XMLHttpRequest();  
     }
     catch (e)
     { 
         // Internet Explorer  
         try
         {    
               xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    
         }
         catch (e)
         {    
               try
               {      
                     xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");     
               }
               catch (e)
               {      
                     //alert("Your browser does not support AJAX!");      
                     return false;      
               }    
         }  
     }
   
     xmlHttp.onreadystatechange=function()
     {
         if(xmlHttp.readyState==4)
         {
               //document.getElementById("txt").value=xmlHttp.responseText;
         }
     }
	 sURL = sURL + "?" + "allf_popid=" + sAllf_popid + "&allf_locus=" + sAllf_locus + "&allf_allele=" + sAllf_allele + "&allf_pfreq=" + sAllf_pfreq + "&allf_afreq=" + sAllf_afreq;
     xmlHttp.open("GET", sURL, true);
     xmlHttp.send(null);  
}
function ajaxhla2001a_upt(sAllf_popid, sURL2, iAction)
{
    var xmlHttp;
	var sURL = "ajaxhla2001a_upt.asp";
	var sResponse = "";
	
	if (iAction == 1)
		var bAgree=confirm("Do you want to lock this record?");
	else
		var bAgree=confirm("Do you want to unlock this record?");
		
	if (bAgree)
	{		
		try
		{  
			 // Firefox, Opera 8.0+, Safari  
			 xmlHttp=new XMLHttpRequest();  
		 }
		 catch (e)
		 { 
			 // Internet Explorer  
			 try
			 {    
				   xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    
			 }
			 catch (e)
			 {    
				   try
				   {      
						 xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");     
				   }
				   catch (e)
				   {      
						 //alert("Your browser does not support AJAX!");      
						 return false;      
				   }    
			 }  
		 }
	   
		 xmlHttp.onreadystatechange=function()
		 {
			 if(xmlHttp.readyState==4)
			 {
				   window.location="pop0009a.asp?" + sURL2;				 
				   //sResponse = xmlHttp.responseText;
				   //if(sResponse != "")
				   //{
					//	if (sResponse == "A")
						//{
							//	document.getElementById("imgDelPop"+sAllf_popid).src="images/icon_active.gif";
							//	document.getElementById("imgStatPop"+sAllf_popid).src="images/icon_web.gif";								
					//	}
					//	else
					//	{
							//	document.getElementById("imgDelPop"+sAllf_popid).src="images/icon_inactive.gif";
							//	document.getElementById("imgStatPop"+sAllf_popid).src="images/icon_pending.gif";								
					//	}
				   //}
			 }
		 }
		 sURL = sURL + "?" + "allf_popid=" + sAllf_popid;
		 xmlHttp.open("GET", sURL, true);
		 xmlHttp.send(null);  
	}
	else
	{
		return false;
	}
}
